<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js">
    </script>
</head>

<body ng-app="myApp">
    <script>
        var app = angular.module("myApp", []);
        app.directive("myangularjs", function () {
            return {
                template: "<h3>这是自定义指令!</h3>"
            };
        });
    </script>
    <!-- 通过元素名 -->
    <myangularjs></myangularjs>
    <!-- 通过属性 -->
    <div myangularjs></div>
    <!-- 通过类名 需设置 restrict:C -->
    <div class="myangularjs"></div>
    <!-- 通过注解 需设置 restrict:M,replace:true -->
    <!-- directive: myangularjs -->
</body>

</html>